<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<!--
		Charisma v1.0.0

		Copyright 2012 Muhammad Usman
		Licensed under the Apache License v2.0
		http://www.apache.org/licenses/LICENSE-2.0

		http://usman.it
		http://twitter.com/halalit_usman
	-->
<meta charset="utf-8">
	<title>友宝后台管理系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
	content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
<meta name="author" content="Muhammad Usman">

<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
<link href='css/fullcalendar.css' rel='stylesheet'>
<link href='css/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='css/chosen.css' rel='stylesheet'>
<link href='css/uniform.default.css' rel='stylesheet'>
<link href='css/colorbox.css' rel='stylesheet'>
<link href='css/jquery.cleditor.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
<link href='css/opa-icons.css' rel='stylesheet'>
<link href='css/uploadify.css' rel='stylesheet'>

<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
	  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">

</head>

<body>
	<s:include value="header.jsp" />
	<!-- topbar ends -->
	<div class="container-fluid">
		<div class="row-fluid">

			<s:include value="left.jsp" />

			<noscript>
				<div class="alert alert-block span10">
					<h4 class="alert-heading">Warning!</h4>
					<p>
						You need to have <a href="http://en.wikipedia.org/wiki/JavaScript"
							target="_blank">JavaScript</a> enabled to use this site.
					</p>
				</div>
			</noscript>

			<div id="content" class="span10">
				<!-- content starts -->


				<div>
					<ul class="breadcrumb">
						<li><a href="index">主页</a> <span class="divider">/</span></li>
						<li><a href="#">授权卡信息修改</a></li>
					</ul>
				</div>
				<input id="oldSernum" type="hidden" value= "<s:property value="card.sernum" />" type="text" />
				<input id="oldRfid" type="hidden" value= "<s:property value="card.rfid" />" type="text" />
				<div class="sortable row-fluid">
					<div class="box-content">
						<form class="form-horizontal" action="editCard?cardID=<s:property value="card.id" />" method="post" id="form">
						  <fieldset>
							<div class="control-group">
							  <label class="control-label" for="typeahead">序列号:</label>
							  <div class="controls">
								<input name="card.sernum" value="<s:property value="card.sernum" />" type="text" class="span4 typeahead" id="sernum" data-items="2" style="float: left;"/>
							  </div>
							</div>
							<div class="control-group">
							  <label class="control-label" for="typeahead">RFID:</label>
							  <div class="controls">
								<input name="card.rfid" maxlength="8" value="<s:property value="card.rfid" />" type="text" class="span4 typeahead" id="rfid" data-items="2" style="float: left;"/>
							  </div>
							</div>
							  <div class="form-actions">
								<button type="button" class="btn btn-primary" id="subBtn">修改</button>
								<button class="btn" type="button" onclick="window.history.go(-1);">Cancel</button>
							  </div>																					
						  </fieldset>
						</form> 
					</div>
				</div>
				<!-- content ends -->
			</div>
			<!--/#content.span10-->
		</div>
		<!--/fluid-row-->

		<hr>

		<div class="modal hide fade" id="myModal">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">Ã</button>
				<h3>Settings</h3>
			</div>
			<div class="modal-body">
				<p>Here settings can be configured...</p>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">Close</a> <a href="#"
					class="btn btn-primary">Save changes</a>
			</div>
		</div>

	<s:include value="footer.jsp" />

	</div>
	<!--/.fluid-container-->

	<!-- external javascript
	================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<!-- jQuery -->
	<script src="js/jquery-1.7.2.min.js"></script>
	<!-- jQuery UI -->
	<script src="js/jquery-ui-1.8.21.custom.min.js"></script>
	<!-- transition / effect library -->
	<script src="js/bootstrap-transition.js"></script>
	<!-- alert enhancer library -->
	<script src="js/bootstrap-alert.js"></script>
	<!-- modal / dialog library -->
	<script src="js/bootstrap-modal.js"></script>
	<!-- custom dropdown library -->
	<script src="js/bootstrap-dropdown.js"></script>
	<!-- scrolspy library -->
	<script src="js/bootstrap-scrollspy.js"></script>
	<!-- library for creating tabs -->
	<script src="js/bootstrap-tab.js"></script>
	<!-- library for advanced tooltip -->
	<script src="js/bootstrap-tooltip.js"></script>
	<!-- popover effect library -->
	<script src="js/bootstrap-popover.js"></script>
	<!-- button enhancer library -->
	<script src="js/bootstrap-button.js"></script>
	<!-- accordion library (optional, not used in demo) -->
	<script src="js/bootstrap-collapse.js"></script>
	<!-- carousel slideshow library (optional, not used in demo) -->
	<script src="js/bootstrap-carousel.js"></script>
	<!-- autocomplete library -->
	<script src="js/bootstrap-typeahead.js"></script>
	<!-- tour library -->
	<script src="js/bootstrap-tour.js"></script>
	<!-- library for cookie management -->
	<script src="js/jquery.cookie.js"></script>
	<!-- calander plugin -->
	<script src='js/fullcalendar.min.js'></script>
	<!-- data table plugin -->
	<script src='js/jquery.dataTables.min.js'></script>

	<!-- chart libraries start -->
	<script src="js/excanvas.js"></script>
	<script src="js/jquery.flot.min.js"></script>
	<script src="js/jquery.flot.pie.min.js"></script>
	<script src="js/jquery.flot.stack.js"></script>
	<script src="js/jquery.flot.resize.min.js"></script>
	<!-- chart libraries end -->

	<!-- select or dropdown enhancer -->
	<script src="js/jquery.chosen.min.js"></script>
	<!-- checkbox, radio, and file input styler -->
	<script src="js/jquery.uniform.min.js"></script>
	<!-- plugin for gallery image view -->
	<script src="js/jquery.colorbox.min.js"></script>
	<!-- rich text editor library -->
	<script src="js/jquery.cleditor.min.js"></script>
	<!-- notification plugin -->
	<script src="js/jquery.noty.js"></script>
	<!-- file manager library -->
	<script src="js/jquery.elfinder.min.js"></script>
	<!-- star rating plugin -->
	<script src="js/jquery.raty.min.js"></script>
	<!-- for iOS style toggle switch -->
	<script src="js/jquery.iphone.toggle.js"></script>
	<!-- autogrowing textarea plugin -->
	<script src="js/jquery.autogrow-textarea.js"></script>
	<!-- multiple file upload plugin -->
	<script src="js/jquery.uploadify-3.1.min.js"></script>
	<!-- history.js for cross-browser state change on ajax -->
	<script src="js/jquery.history.js"></script>
	<!-- application script for Charisma demo -->
	<script src="js/charisma.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#subBtn").click(function(){
				var sernum = false;
				var rfid = false;
				var temp = $("#sernum").val().toUpperCase().substring(0, 3);
				 var type = null;
				 if(temp=="KSQ"){
					 type="1";
				}else if(temp=="ASQ"){
					type="0";
				}else if(temp=="USQ"){
					type="2";
				}else if(temp=="UVS"){
					type="3";
				}else{
					type="4";
				}
				 if($("#sernum").val()==""){   //验证序列号唯一
					 alert("序列号不能为空！");
					 sernum = false;
				 	 return false;
				 }else if(type=="4"){
					 alert("必须以KSQ，ASQ，USQ，UVSQ开头！");
					 sernum = false;
					 return false;
				 }else if($("#sernum").val().length!=11){
					 alert("序列号长度为11位！");
					 sernum = false;
					 return false;
				 }else{
				     var  re=/^[\u4E00-\u9FA5]*$/;
					 if(re.test($("#sernum").val())){
						 alert("序列号只能为数字和字母！");
						 sernum = false;
						 return false;
					 }else{
						 if($("#sernum").val()==$("#oldSernum").val()){
							 sernum = true;
						 }else{
						 $.ajax({
							  url: "card!checkValue?flag=sernum&value="+$("#sernum").val(),
							  async: false,
							  success: function(data){
								  if(data==1){
									  alert("该序列号已存在，请重新输入！");
									  sernum = false;
									   return false;
								   }else{
									   sernum = true;
								   }
							  }
							});
						 }
					 }
				 }
				 if($("#rfid").val()==""){  //验证rfid唯一
					 alert("rfid不能为空！");
					 rfid = false;
					 return false;
				 }else if($("#rfid").val().length!=8){
					 alert("rfid的长度为8！");
					 rfid = false;
					 return false;
				 }else{
				     var  re=/^[\u4E00-\u9FA5]*$/;
					 if(re.test($("#rfid").val())){
						 alert("rfid只能为数字和字母！");
						 rfid = false;
						 return false;
					 }else{
						 if($("#rfid").val()==$("#oldRfid").val()){
							 rfid = true;
						 }else{
						 $.ajax({
							  url: "card!checkValue?flag=rfid&value="+$("#rfid").val(),
							  async: false,
							  success: function(data){
								  if(data==1){
									  alert("该rfid已存在，请重新输入！");
									  rfid = false;
									   return false;
								   }else{
									   rfid = true;
								   }
							  }
							});
						 }
					 }
				 }
				 if(sernum==true&&rfid==true){
					alert("添加成功！");
					$("form").submit();
				}else{
					alert("添加失败！");
				}
			});
		});
	</script>
</body>
</html>
